class Solution {
    public void rotate(int[] nums, int k) {
        if(k == 0 || k == nums.length) {
            return;
        }
        int length = nums.length;
        k = k % length;
        int[] sum = new int[length];
        int a = 0;
        for(int i = length-k;i < length;i++) {
            sum[a] = nums[i];
            a++;
        }
        for(int i = 0;i < length-k;i++) {
            sum[a] = nums[i];
            a++;
        }
        for(int i = 0;i < length;i++) {
            nums[i] = sum[i];
        }
    }
}